package example;
import facecat.topin.core.*;
import facecat.topin.xml.*;
import facecat.topin.grid.*;
import facecat.topin.div.*;
import facecat.topin.tab.*;
import facecat.topin.swing.*;

/*
 * 表格示例
 */
public class GridExample extends FCUIXml
{
    /*
     * 加载Xml
     * @param fileName 文件名
     * @param view 视图名称
     */
   public void loadXml(String fileName, FCView view)
   {
       setScript(new FaceCatScript(this));
       super.loadXml(fileName, view);
       FCGrid grid = getGrid("Grid");
       //获取第二页
       FCTabPage tabPage = getTabPage("TabPage2");
       FCGrid newGrid = new FCGrid();
       newGrid.setLocation(new FCPoint(50, 50));
       newGrid.setSize(new FCSize(400, 400));
       tabPage.addView(newGrid);

       for (int i = 0; i < 10; i++)
       {
           newGrid.addColumn(new FCGridColumn("Column" + FCTran.intToStr(i)));
       }
       newGrid.update();
       for (int i = 0; i < 1000; i++)
       {
           FCGridRow row = new FCGridRow();
           newGrid.addRow(row);
           row.addCell(0, new FCGridStringCell("Cell1"));
           row.addCell(1, new FCGridIntCell(100));
           row.addCell(2, new FCGridDoubleCell(50));
           row.addCell(3, new FCGridBoolCell(true));
           row.addCell(4, new FCGridCheckBoxCell());
           FCGridButtonCell buttonCell = new FCGridButtonCell();
           row.addCell(5, buttonCell);
           buttonCell.getButton().setText("确定");
           row.addCell(6, new FCGridTextBoxCell());
           row.addCell(7, new FCGridLongCell(100));
           FCGridPasswordCell pwdCell = new FCGridPasswordCell();
           pwdCell.setText("1111");
           row.addCell(8, pwdCell);
           FCGridComboBoxCell comboBoxCell = new FCGridComboBoxCell();
           row.addCell(9, comboBoxCell);
           comboBoxCell.getComboBox().addItem(new FCMenuItem("选项1"));
           comboBoxCell.getComboBox().addItem(new FCMenuItem("选项2"));
           comboBoxCell.getComboBox().addItem(new FCMenuItem("选项3"));
           comboBoxCell.getComboBox().setSelectedIndex(0);
       }
       newGrid.update();
   }
}